Ensure that api:openapi:export produces JSON with unescaped forward slashes#3368
Conversation
| use Symfony\Component\Console\Output\BufferedOutput; | ||
| use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
|
||
| class SwaggerCommandUnitTest extends KernelTestCase |
There was a problem hiding this comment.
Note: a unit test was much simpler and efficient to write - the current integration test is not something I could work with anyway, since I don't run MongoDB on any system I maintain (including my dev environment) by choice
There was a problem hiding this comment.
I hope that can be achieved again at some point: for now, I'm happy with adding a unit test, and providing more unit tests in future, shall I encounter isolated issues, like this one.
There was a problem hiding this comment.
PHP extensions are no longer required to be loaded - thanks to Roave/BetterReflection and PhpStorm stubs!
We should be able to do this once we upgrade to phpstan ^0.12.4! 😄
There was a problem hiding this comment.
Unfortunately, we still can't remove the MongoDB packages, because we'd get errors such as:
------ --------------------------------------------------------------------------------------------
Line src/Bridge/Doctrine/Common/Util/IdentifierManagerTrait.php (in context of anonymous class)
------ --------------------------------------------------------------------------------------------
47 Class Doctrine\ODM\MongoDB\DocumentManager not found.
86 Call to static method hasType() on an unknown class Doctrine\ODM\MongoDB\Types\Type.
87 Call to static method getType() on an unknown class Doctrine\ODM\MongoDB\Types\Type.
------ --------------------------------------------------------------------------------------------
😞
There was a problem hiding this comment.
@ondrejmirtes Do you perhaps have any suggestions on how this could be resolved? I see there are MongoDB ODM stubs in https://github.com/phpstan/phpstan-doctrine/tree/master/stubs
Is there a way to tell phpstan that these types "exist" purely based on the stubs?
There was a problem hiding this comment.
Is there a way to tell phpstan that these types "exist" purely based on the stubs?
You'd have to make the class available for the autoloader. See: https://phpstan.org/user-guide/autoloading
0dd8feb to
0d31896
Compare
|
Couldn't this be a BC if the client has been relying on the escaped slashes? |
|
Doubt that, but there is indeed a change in dumped definitions. Forward slashes do not impose an escaping sequence risk. |
|
Thanks @Ocramius! |
This ensures that the generated OpenAPI schema JSON dump does not contain forward-slashes, such as
"#\/foo\/bar\/MyModel", which confuses tooling relying on direct string match in referenced models (most notably, the IntelliJ OpenAPI/Swagger tooling)